package models;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import play.data.validation.MaxSize;
import play.data.validation.Required;

/**
 * 消息
 * @author justin
 *
 */
@Entity
public class Message extends BaseEntity {
	
	public enum MessageType {
		CONSULTING, SUGGEST, REFUND, OTHER, QUESTION
		//咨询           , 建议         , 退款      , 其他   , 匿名咨询(用于在线咨询)
	}
	
	public enum MessageStatus {
		NEW, PASS, FAIL
		//新信息、审核通过、审核不通过
	}
    
	/* 消息标题 */
	public String title;
	
	/* 消息内容 */
	@Required
	@MaxSize(value=200)
	public String content;
	
	/* 匿名用户昵称 */
	public String author;
	
	/* 消息类型 */
	public MessageType type;
	
	/*消息状态*/
	public MessageStatus messageStatus;
	
	/*是否阅读*/
	public boolean isread;
	
	/*管理员发信息给用户*/
	@ManyToOne
	public User toUser;
	
	/* 如果此消息是回覆，则此关联表示回覆的目标消息 */
	@ManyToOne
	public Message target;
	
	/* 此消息的所有回覆 */
	@OneToMany(mappedBy="target", cascade={CascadeType.ALL})
	public List<Message> replys;
}
